import Vue from 'vue'
import Vuex from 'vuex'

//挂载Vuex
Vue.use(Vuex)


export default new Vuex.Store({
    state: {
        address1: '',
        address2: '',

    },
    mutations: {
        //  收件填写地址
        setAddress(state, payload) {
            console.log(payload)
            payload.phone = payload.tel.substr(0, 3) +
                "****" +
                payload.tel.substr(7);
            state.address2 = payload
        },
        //  寄件填写地址
        setAddress3(state, payload) {
            console.log(payload)
            payload.phone = payload.tel.substr(0, 3) +
                "****" +
                payload.tel.substr(7);
            state.address1 = payload
        },
        //    选择地址

        setAddress1(state, payload) {
            payload.phone = payload.tel.substr(0, 3) +
                "****" +
                payload.tel.substr(7);
            state.address1 = payload
        },
        setAddress2(state, payload) {
            payload.phone = payload.tel.substr(0, 3) +
                "****" +
                payload.tel.substr(7);
            state.address2 = payload
        },
        // 清除地址缓存
        clearAddress(state) {
            state.address1 = ''
            state.address2 = ''
        }
    }
})
